<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Notepad</title>

    <!-- bootstrap -->
    <link rel="stylesheet" href="./assets/css/bootstrap.min.css" />

    <!-- animate.css -->
    <link rel="stylesheet" href="./assets/css/animate.min.css" />

    <!-- 重置样式 -->
    <link rel="stylesheet" href="./assets/css/reset.css" />

    <!-- mui框架css -->
    <link rel="stylesheet" href="./assets/plugins/mui/css/mui.min.css">

    <!-- 公共样式 -->
    <link rel="stylesheet" href="./assets/css/common.css" />

    <!-- 页面独立的 -->
    <link rel="stylesheet" href="./assets/css/ContactAdd.css" />
</head>

<body>
    <!-- 信息录入 -->
    <div class="info">
        <h3 class="title wow fadeInUp">分类录入</h3>

        <p class="desc wow fadeInUp" data-wow-delay="200ms" style="color: white;">
            您可在本页录入您的分类信息，录入成功后名片将会出现在首页。
        </p>
    </div>

    <form class="contact wow fadeInUp" data-wow-delay="300ms" method="post">

        <div class="form-group">
            <label for="name">分类名称</label>
            <input type="text" class="form-control" id="name" name="name" placeholder="请输入分类名称" required />
        </div>

        <div class="action">
            <button class="btn" type="submit">提交</button>
        </div>
    </form>
</body>

</html>
<!-- jquery  -->
<script src="./assets/js/jquery.min.js"></script>

<!-- bootstrap -->
<script src="./assets/js/bootstrap.min.js"></script>

<!-- wow.js -->
<script src="./assets/js/wow.min.js"></script>

<!-- mui框架js -->
<script src="./assets/plugins/mui/js/mui.min.js"></script>

<!-- 请求插件 -->
<script src="./assets/plugins/axios/axios.min.js"></script>
<script src="./assets/plugins/axios/request.js"></script>

<!-- 引入cookie -->
<script src="./assets/plugins/cookle.js"></script>
<!-- 校验用户是否登陆 -->
<script src="./assets/plugins/check.js"></script>

<script>
    //实例化wow.js
    new WOW().init();

    let Business = cookie.get('Business') ? JSON.parse(cookie.get('Business')) : {}

    $("form").submit(async function (e) {
        // 阻止默认事件
        e.preventDefault()

        let result = await POST({
            url: 'card/type/add', params: {
                businessid: Business.id,
                name: $("#name").val()
            }
        })

        if (result.code == 1) {
            mui.toast(result.msg);
            setTimeout(() => {
                location.href = 'typeindex.html'
            }, 2000)
        }
        else {
            mui.toast(result.msg);
        }
    });
</script>